<style>
    span {
        display: inline-block;
        width: 20px;
        height: 20px;
        font-size: 30px;
    }
</style>
<?php
// 验证码的生成:
// 随机生成 4个 0~9 a-z 之间的 字符, 组成一个字符串
$str = "0123456789abcdefghijklmnopqrstuvwxyz";
$max = mb_strlen($str) - 1;
$code = "";
for ($i=0; $i < 4; $i++) { 
    $index = mt_rand(0, $max);
    $char = $str[$index];
    $code .= $char;
}
echo "<h3>$code</h3>";

// 生成4个字符的验证码，要求每个字符的颜色随机, 旋转角度随机
$str = "0123456789abcdefghijklmnopqrstuvwxyz";
$max = mb_strlen($str) - 1;
$codeTxt = "";
for ($i=0; $i < 4; $i++) { 
    $index = mt_rand(0, $max);
    $char = $str[$index];
    $r = mt_rand(0, 255);
    $g = mt_rand(0, 255);
    $b = mt_rand(0, 255);
    $deg = mt_rand(-45, 45);
    $codeTxt .= "<span style='color: rgb($r,$g,$b);transform: rotate({$deg}deg);' >$char</span>";
}
echo $codeTxt;
?>